<?php

use app\helpers\BookHelper;
use app\models\Book;
use app\models\BookItem;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\web\View;

/* @var $item BookItem */

/* @var $this View */

/* @var $book Book */
/* @var $item BookItem */

$book = $this->params['book'];
$item = $this->params['item'];
$items = $this->params['items'];
$next_url = $this->params['next_url'];
$prev_url = $this->params['prev_url'];

?>
<nav class="book-item-tool">
    <ul class="nav mr-2">
        <?php if(!$this->params['is_favorite']): ?>
        <li class="nav-item">
            <a class="nav-link favorite tooltip tooltip-top" data-tooltip="收藏" href="javascript:void(0);" data-href="<?= Url::to(['user/save-favorite', 'id' => $book['id']]); ?>"><i class="icon-star-o"></i></a>
        </li>
        <?php endif; ?>
        <?php if($prev_url): ?>
        <li class="nav-item">
            <a class="nav-link tooltip tooltip-top" data-tooltip="上一话" href="<?= $prev_url; ?>"><i class="icon-long-arrow-left"></i></a>
        </li>
        <?php endif ?>
        <?php if($next_url): ?>
        <li class="nav-item">
            <a class="nav-link tooltip tooltip-top" data-tooltip="下一话" href="<?= $next_url; ?>" title="下一话"><i class="icon-long-arrow-right"></i></a>
        </li>
        <?php endif ?>
        <li class="nav-item">
            <a class="nav-link book-item-list-button tooltip tooltip-top" title="目录" data-tooltip="目录" href="javascript:void(0);"><i class="icon-list"></i></a>
        </li>
        <li class="nav-item"><a class="bulb nav-link tooltip tooltip-top" data-tooltip="开灯" href="javascript:void(0);"><i class="icon-bulb"></i></a></li>
    </ul>

    <div class="book-item-dialog" style="display: none;">
        <h3 class="title">《<?= Html::encode($book['title']); ?>》目录</h3>
        <ul class="list-group">
            <?php foreach ($items as $k => $v): ?>
                <li class="list-group-item">
                    <a class="<?= $v['id'] == $item['id'] ? 'active' : ''; ?>" href="<?= Url::to(['comic/item', 'id' => $book['id'], 'itemId' => $v['id']]); ?>"><span class="name"><?= BookHelper::getFullBookItemName($v); ?></span></a>
                </li>
            <?php endforeach; ?>
        </ul>

    </div>
</nav>
